{include file='common/head.html'}

<div class="layui-body">
	{if([$list])}
	<div class="layui-tab layui-tab-brief" lay-filter="tab">
	  <ul class="layui-tab-title">
	    <li class="layui-this" lay-id="t1">文章类型</li>
	    <li lay-id="t2">添加一级类型</li>
	  </ul>
	  <div class="layui-tab-content">
	  	   <div class="layui-tab-item layui-show">
			   <form action="{url./admin/ContentType/mod}" method="post" id="typeForm" name="typeForm">
				   <input type="hidden" name="formcheck" value="{$formcheck}" >
				   <table class="layui-table" id="sortTable">
					   <thead>
					   <tr>
						   <th>ID</th>
						   <th>名称</th>
						   <th>排序</th>
						   <th>副标题</th>
						   <th>标签</th>
						   <th>状态</th>
						   <th>操作</th>
					   </tr>
					   </thead>
					   <tbody>
					   {foreach $types(key,value)}

					   <tr data-tt-id='[value->id]' data-tt-parent-id="[value->pid]">
						   <td>
							   [value->id]
						   </td>
						   <td>
							   {if($value->son)}
							   <i class="fa fa-folder-o" aria-hidden="true"></i>
							   {else}
							   <i class="fa fa-folder-open-o" aria-hidden="true"></i>
							   {/if}
							   [value->name]
						   </td>
						   <td class="table-input"><input type="text" name="sorting[]" value="[value->sorting]" class="layui-input"></td>

						   <td>[value->subtitle]</td>
						   <td>[value->tag]</td>

						   <td>
							   {if($value->status)}
							   <a href="{url./admin/'.C.'/mod/id/'.$value->id.'/field/status/value/0}" class="switch"><i class='fa fa-toggle-on' title="点击禁用"></i></a>
							   {else}
							   <a href="{url./admin/'.C.'/mod/id/'.$value->id.'/field/status/value/1}" class="switch"><i class='fa fa-toggle-off' title="点击启用"></i></a>
							   {/if}
						   </td>
						   <td>

							   {fun=get_btn('添加子类型','layui-btn-normal','mod',$value->id,'pid')}
							   {fun=get_btn_mod($value->id,'id')}
							   {fun=get_btn_del($value->id,'id')}
						   </td>
					   </tr>
					   {/foreach}
					   </tbody>
				   </table>
				   <button type="submit" name="submit" value="sorting" class="layui-btn">保存排序</button>
				   <script>
                       $("#sortTable").treetable({ expandable: true,column: 1,indent:20,stringCollapse:'收缩',stringExpand:'展开' });
				   </script>
			   </form>
	  	    </div>
	  	    
	  	     <div class="layui-tab-item">
	  	     	<form action="{url./admin/ContentType/add}" method="post" class="layui-form" lay-filter="type">
		  	     	<input type="hidden" name="formcheck" value="{$formcheck}" >

					<div class="layui-form-item">
						<label class="layui-form-label">父类型</label>
						<div class="layui-input-block">
							<input type="hidden" name="pid" value="0" class="layui-input">
							<select name="pid" disabled>
								<option value="0" >顶级栏目</option>
								{$type_select}
							</select>
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">类型名称 <span class="layui-text-red">*</span></label>
						<div class="layui-input-block">
							<input type="text" name="name" required lay-verify="required" placeholder="请输入类型名称" class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
							<label class="layui-form-label">排序</label>
							<div class="layui-input-block">
								<input type="text" name="sorting" lay-verify="required|number" placeholder="排序" autocomplete="off" class="layui-input" value="255">
							</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">副标题</label>
						<div class="layui-input-block">
							<input type="text" name="subtitle"  autocomplete="off" placeholder="请输入副标题" class="layui-input"  value="">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">标签</label>
						<div class="layui-input-block">
							<input type="text" name="tag"  autocomplete="off" placeholder="请输入标签" class="layui-input"  value="">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">是否可用</label>
						<div class="layui-input-block">
								<input type="radio" name="status" value="1" title="是" checked />
								<input type="radio" name="status" value="0" title="否" />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">资讯类别封面</label>
						<div class="layui-input-inline">
							<input type="text" name="pic" id="pic" placeholder="请上传图片"  class="layui-input">
						</div>
						<button type="button" class="layui-btn upload" data-des="pic">
							<i class="layui-icon">&#xe67c;</i>上传图片
						</button>
						<div id="pic_box" class="pic"></div>
					</div>

					<div class="layui-form-item">
						 <div class="layui-input-block">
						    <button class="layui-btn" lay-submit>立即提交</button>
						    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
						 </div>
					</div>
				</form>
	  	     </div>
	   </div>
	</div>
	{/if} 
	
	{if([$mod])}
	<div class="layui-tab layui-tab-brief" lay-filter="tab">
	  <ul class="layui-tab-title">
	    <li class="layui-this">修改文章类型</li>
	  </ul>
	  <div class="layui-tab-content">
	  	<div class="layui-tab-item layui-show">
	  		<form action="{url./admin/ContentType/'. [$method] .'/id/'.[$get.id].'}{$backurl}" method="post" class="layui-form" lay-filter="type">
	  	     	<input type="hidden" name="formcheck" value="{$formcheck}" >

				<div class="layui-form-item">
					<label class="layui-form-label">父类型</label>
					<div class="layui-input-block">
						<input type="hidden" name="pid" value="{$type->pid}" class="layui-input">
						<select name="pid" disabled>
							<option value="0" >顶级栏目</option>
							{$type_select}
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">类型名称 <span class="layui-text-red">*</span></label>
					<div class="layui-input-block">
						<input type="text" name="name" value="{$type->name}" required lay-verify="required" placeholder="请输入类型名称" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">排序</label>
					<div class="layui-input-block">
						<input type="text" name="sorting" lay-verify="required|number" placeholder="排序" autocomplete="off" class="layui-input" value="{$type->sorting}">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">副标题</label>
					<div class="layui-input-block">
						<input type="text" name="subtitle"  autocomplete="off" placeholder="请输入副标题" class="layui-input"  value="{$type->subtitle}">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">标签</label>
					<div class="layui-input-block">
						<input type="text" name="tag"  autocomplete="off" placeholder="请输入标签" class="layui-input"   value="{$type->tag}">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">是否可用</label>
					<div class="layui-input-block">
						<input type="radio" name="status" value="1" title="是" {if([$type->status])}checked{/if} />
						<input type="radio" name="status" value="0" title="否" {if(![$type->status])}checked{/if} />
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">资讯类别封面</label>
					<div class="layui-input-inline">
						<input type="text" name="pic" id="pic" value="{$type->pic}" placeholder="请上传图片"  class="layui-input">
					</div>
					<button type="button" class="layui-btn upload" data-des="pic">
						<i class="layui-icon">&#xe67c;</i>上传图片
					</button>
					<div id="pic_box" class="pic">{if([$type->pic])}<dl><dt><img src="{SITE_DIR}{$type->pic}" data-url="{$type->pic}"></dt><dd>删除</dd></dl>{/if}</div>
				</div>


				<div class="layui-form-item">
					 <div class="layui-input-block">
					    <button class="layui-btn" lay-submit>立即提交</button>
					    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
					    {fun=get_btn_back()}
					 </div>
				</div>
			</form>
	  	</div>
	  </div>
	</div>
	{/if} 
</div>

{include file='common/foot.html'}
